import request from 'umi-request';

export async function queryPromotionList(params,value,type = {}) {
  return request('/hr-ssc/api/api-admin/promotion/getPromotionList', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      status:parseInt(value),
      isSelf:1,
      promotionKind:0,
      promotionType:type,
      userCode:params.code,
      name:params.name,
    },
  }).then((res) => {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
  });
}

export async function getDepartmentUser(orgId) {
  return request(`/hr-ssc/api/api-admin/roleAssignment/getDepartmentUser?orgId=${orgId}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getJobByOrgId(id) {
  return request(`/hr-ssc/api/api-admin/job/findJobByOrgId/${id}`, {
    method: 'get'
  }).then((res) => {
    return res.data;
  });
}

export async function queryBatchList(params,type) {
  return request('/hr-ssc/api/api-admin/promotion/getBatchList', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      type:type,
      batchCode:params.batchCode,
      userCode:params.userCode,
      promotionCode:params.promotionCode
    },
  }).then((res) => {
    const data = res.data;
    return {
      current: data.currPage,
      data: data.list,
      pageSize: data.pageSize,
      success: true,
      total: data.totalCount,
    };
  });
}

export async function getBatchDetail(id) {
  return request('/hr-ssc/api/api-admin/promotion/getBatchDetail', {
    method: 'post',
    data: {id},
    requestType: 'form'
  }).then((res) => {
    const data = res.data;
    return {
      data: data,
      success: true,
    };
  });
}
